package com.cndw.kungfu.model.pvp.camp;

import org.springframework.beans.factory.annotation.Autowired;

import com.cndw.kungfu.domain.Player;
import com.cndw.kungfu.model.battle.Fighter;

/**
 * 参加阵营战的玩家对象
 * 
 * @author fantadust [9677889@qq.com]
 * @date 2012-8-5 下午4:59:34
 */
public class CampWarPlayer implements CampWarPlayerI {

	private long id;

	private boolean source;

	private int area;

	private int win;

	private int all;

	private int streak;

	private int buff;

	private transient Player sourceObj;

	private boolean act;
	
	@Autowired
	public long getId() {
		return id;
	}
	public void setId(long playerId) {
		this.id = playerId;
	}
	@Autowired
	public boolean isSource() {
		return source;
	}

	public void setSource(boolean source) {
		this.source = source;
	}

	public int getArea() {
		return area;
	}

	public void setArea(int area) {
		this.area = area;
	}

	public int getWin() {
		return win;
	}

	public void setWin(int wTimes) {
		this.win = wTimes;
	}

	public int getAll() {
		return all;
	}

	public void setAll(int bTimes) {
		this.all = bTimes;
	}
	@Autowired
	public int getStreak() {
		return streak;
	}

	public void setStreak(int streakWin) {
		this.streak = streakWin;
	}

	public int getBuff() {
		return buff;
	}

	public void setBuff(int buff) {
		this.buff = buff;
	}

	public Player getSourceObj() {
		return sourceObj;
	}

	public void setSourceObj(Player sourceObj) {
		this.sourceObj = sourceObj;
	}
	@Autowired
	public boolean isAct() {
		return act;
	}

	public void setAct(boolean act) {
		this.act = act;
	}
	@Autowired
	public void notifyWin(boolean isWin) {
		all++;
		if (isWin) {
			win++;
			streak++;
		} else {
			streak = 0;
		}

	}

	public Object[] toObj() {
		return new Object[] { area, source, id, sourceObj.getPlayerName() };
	}

	public CampRecord toRecord() {
		CampRecord record = new CampRecord();
		record.setId(id);
		record.setWin(win);
		record.setStreak(streak);
		record.setAll(all);
		return record;
	}

	public int getSign() {
		return source ? area * 2 + 1 : area * 2 + 2;
	}

	@Override
	public Fighter getFighter() {
		return sourceObj.getLikedFighter(buff);
	}

	@Override
	public int[] blodMagicMemory() {
		return sourceObj.blodMagicMemory();
	}

	@Override
	public void award(int asset, int achive) {
		sourceObj.alterAsset(asset);
		sourceObj.getDataInfo().alterAchive(achive);
		sourceObj.commitSync();
		sourceObj.getDataInfo().commitSync();
	}

	@Override
	public void blodMagicMemoryRevert(int[] hpMps) {
		sourceObj.blodMagicMemoryRevert(hpMps);
	}

	@Override
	public String getName() {
		return sourceObj.getPlayerName();
	}

	@Override
	public Player getPlayerObj() {
		return sourceObj;
	}
	
	

}
